home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 1 / Gekikoh Dennoh Club Vol. 1 (Japan).7z / Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin / kowin / archive / net / k20menus.lzh / k20input.c < prev    next >
C/C++ Source or Header  |  1994-10-12  |  15KB  |  664 lines

  1. /*    Copyright 1992 H.Ogasawara(COR.)    */
  2.  
  3. #include    <corlib.h>
  4. #include    <sys_doslib.h>
  5.  
  6. #define        XO    4        /* window offset */
  7. #define        YO    4
  8. #define        HS    (6*58)        /* window size */
  9. #define        VS    (15*15-6)
  10. #define        IOFF    4        /* title and box */
  11. #define        BOFF    1        /* box offset */
  12.  
  13. #define        Ctrl(a)    ((a)&0x1f)
  14.  
  15. #define        DEBUG    FALSE
  16.  
  17. extern char    Yankbuf[];
  18.  
  19. extern        attr;
  20.  
  21. char    *pmenu[]= {
  22.         " Paste",
  23.         "設定登録",
  24.         "--------",
  25.         "設定削除",
  26.         "--------",
  27.         " 全消去",
  28.         "--------",
  29.         "設定取消",
  30.     };
  31. #define    MENUS    (sizeof pmenu/sizeof(char*))
  32.  
  33. typedef struct {
  34.     short    x, y;
  35.     short    imax;
  36.     char    *title;
  37. } T_DIAG;
  38.  
  39. typedef struct {
  40.     char    ibuf[40];
  41.     InputClass    ip;
  42.     T_DIAG    *tp;
  43.     char    rs;
  44. } T_IBUF;
  45.  
  46. T_DIAG    tb[]= {
  47.     {  0*6+XO, 0*15+YO, 8, "識別子(Key)   " },
  48.     { 26*6+XO, 0*15+YO, 6, "料金区域 " },
  49.     { 44*6+XO, 0*15+YO, 6, "OPT " },
  50.     {  0*6+XO, 1*15+YO,40, "ネット名      " },
  51.     {  0*6+XO, 2*15+YO,40, "電話番号      " },
  52.     {  0*6+XO, 3*15+YO,40, "ログファイル  " },
  53.     {  0*6+XO, 4*15+YO,40, "モデムコマンド" },
  54.     {  0*6+XO, 5*15+YO,18, "アクセス手順1" },
  55.     { 35*6+XO, 5*15+YO,18, ">" },
  56.     {  0*6+XO, 6*15+YO,18, "アクセス手順2" },
  57.     { 35*6+XO, 6*15+YO,18, ">" },
  58.     {  0*6+XO, 7*15+YO,18, "アクセス手順3" },
  59.     { 35*6+XO, 7*15+YO,18, ">" },
  60.     {  0*6+XO, 8*15+YO,18, "アクセス手順4" },
  61.     { 35*6+XO, 8*15+YO,18, ">" },
  62.     {  0*6+XO, 9*15+YO,18, "アクセス手順5" },
  63.     { 35*6+XO, 9*15+YO,18, ">" },
  64.     {  0*6+XO,10*15+YO,18, "アクセス手順6" },
  65.     { 35*6+XO,10*15+YO,18, ">" },
  66. };
  67.  
  68. #define        LN    (sizeof tb/sizeof(T_DIAG))
  69.  
  70. /*
  71. [ 9600]bps [8]bit [NonP] stop[1  ] SFlow[O] HFlow[O]漢字[SJIS]
  72. 識別子(Key)   [00000000]  料金区域[市内  ]  OPT[0    ]
  73. ネット名      [                                      ]
  74. 電話番号      [                                      ]
  75. ログファイル  [                                      ]
  76. モデムコマンド[                                      ]
  77. アクセス手順1 [Command           ][c denden\r        ]
  78. アクセス手順2 [-->               ][\r                ]
  79. アクセス手順3 [>                 ][ID\r              ]
  80. アクセス手順4 [Passwd            ][******\r          ]
  81. アクセス手順5 [                  ][                  ]
  82. アクセス手順6 [                  ][                  ]
  83.  bps  BIT パリティ STOP Sフロー Hフロー  漢字
  84. [       |       |       |       |       |       |       ]
  85.  9600bps ビット長8 パリティナシ STOP 1  XON/OFF RTS/CTS  SJIS
  86.   19200  ビット長7 パリティ偶 STOP1.5  なし    なし    新JIS
  87.   38400  ビット長6 パリティ奇 STOP 2            EUC
  88.                           旧JIS
  89.                           NECJIS
  90.  全データ転送                取消   設定
  91. */
  92.  
  93. char    *rs1[]={
  94.     " 38400 ",
  95.     " 19200 ",
  96.     "9600bps",
  97.     "4800bps",
  98.     "2400bps",
  99.     "1200bps",
  100.     " 600bps",
  101.     " 300bps",
  102.     " 150bps",
  103.     "  75bps",
  104.     },
  105.     *rs2[]={
  106.     "ビット長8",
  107.     "ビット長7",
  108.     "ビット長6",
  109.     "ビット長5",
  110.     },
  111.     *rs3[]={
  112.     "パリティナシ",
  113.     "パリティ偶",
  114.     "パリティ奇",
  115.     },
  116.     *rs4[]={
  117.     "STOP 1 ",
  118.     "STOP1.5",
  119.     "STOP 2 ",
  120.     },
  121.     *rs5[]={
  122.     "XON/OFF",
  123.     "Sフロー ナシ",
  124.     },
  125.     *rs6[]={
  126.     "RTS/CTS",
  127.     "Hフロー ナシ",
  128.     },
  129.     *rs7[]={
  130.     " S-JIS ",
  131.     "  EUC  ",
  132.     " 新JIS ",
  133.     " 旧JIS ",
  134.     "NEC-JIS",
  135.     };
  136. char    *ss1[]={
  137.     "38400",
  138.     "19200",
  139.     "9600",
  140.     "4800",
  141.     "2400",
  142.     "1200",
  143.     "600",
  144.     "300",
  145.     "150",
  146.     "75",
  147.     },
  148.     *ss2[]={
  149.     "8",
  150.     "7",
  151.     "6",
  152.     "5",
  153.     },
  154.     *ss3[]={
  155.     "N",
  156.     "E",
  157.     "O",
  158.     },
  159.     *ss4[]={
  160.     "1",
  161.     "1.5",
  162.     "2",
  163.     },
  164.     *ss5[]={
  165.     "X",
  166.     "N",
  167.     },
  168.     *ss6[]={
  169.     "ON",
  170.     "OFF",
  171.     },
  172.     *ss7[]={
  173.     "SJIS",
  174.     "EUC",
  175.     "JIS",
  176.     "JISO",
  177.     "NEC",
  178.     };
  179.  
  180. struct {
  181.     char    **rs, **ss;
  182.     short    len;
  183.     } rstbl[]= {
  184.         { rs1, ss1, (sizeof rs1/sizeof(char*)) },
  185.         { rs2, ss2, (sizeof rs2/sizeof(char*)) },
  186.         { rs3, ss3, (sizeof rs3/sizeof(char*)) },
  187.         { rs4, ss4, (sizeof rs4/sizeof(char*)) },
  188.         { rs5, ss5, (sizeof rs5/sizeof(char*)) },
  189.         { rs6, ss6, (sizeof rs6/sizeof(char*)) },
  190.         { rs7, ss7, (sizeof rs7/sizeof(char*)) },
  191.     };
  192.  
  193. #define    FONT    12
  194. #define    ATTR    attr    /*AttrDefault*/
  195. #define    BUFS    80
  196.  
  197. T_IBUF    *tpi;
  198.  
  199. mod_netlist( tp, del )
  200. T_IBUF    *tp;
  201. {
  202.     char    lbuf[512];
  203.     ConsoleOpen();
  204.     if( !*tp->ibuf ){
  205.         ConsolePrint( "k20menu: Key が未設定です\r\n" );
  206.         return    FALSE;
  207.     }
  208.     ConsolePrint( "k20menu:ファイル書き換え中\r\n" );
  209.     if( del )
  210.         *lbuf= '\0';
  211.     else
  212.         makelist( lbuf, tp );
  213.     if( !add_netlist( lbuf, tp->ibuf ) ){
  214.         ConsolePrint( "k20menu:ファイル書き換えに失敗しました\r\n" );
  215.     }else{
  216.         ConsolePrint( "k20menu:データを再読み込みしています\r\n" );
  217.         ReRead();
  218.         ConsolePrint( "k20menu:正常終了\r\n" );
  219.     }
  220.     return    TRUE;
  221. }
  222.  
  223. #if 0
  224. f__open( file, tp, n, mode )    /* 0:add 1:mod 2:del */
  225. unsigned char    *file;
  226. T_IBUF        *tp;
  227. {
  228. #define    SSIZE    512
  229.     FILE    *fp;
  230.     unsigned char    sbuf[SSIZE],
  231.             temp[80],
  232.             backup[80];
  233.     strcpy( temp, "a_$_bcde.tmp" );
  234.     strcpy( backup, "net_menu.bak" );
  235.     if( fp= fopen( file, "r" ) ){
  236.         FILE    *fo;
  237.         if( fo= fopen( temp, "w" ) ){
  238.             for(; n-- && fgets( sbuf, SSIZE, fp ) ;)
  239.                 fputs( sbuf, fo );
  240.             if( mode == 1 ){
  241.                 makelist( sbuf, tp );
  242.                 fputs( sbuf, fp );
  243.                 putc( '\n', fp );
  244.             }
  245.             for(; fgets( sbuf, SSIZE, fp ) ;)
  246.                 fputs( sbuf, fo );
  247.             fclose( fo );
  248.             fclose( fp );
  249.             RENAME( file, backup );
  250.             RENAME( temp, file );
  251.             return    TRUE;
  252.         }
  253.         fclose( fp );
  254.     }
  255.     return    FALSE;
  256. }
  257. #endif
  258.  
  259. char *
  260. makers( str, tp )
  261. unsigned char    *str;
  262. T_IBUF    *tp;
  263. {
  264.     int    i;
  265.     *str= '"';
  266.     str[1]= '\0';
  267.     for( i= 0 ; i< 7 ; i++ ){
  268.         strcat( str, rstbl[i].ss[tp[i].rs] );
  269.         strcat( str, " " );
  270.     }
  271.     strcat( str, "\"" );
  272.     return    str;
  273. }
  274.  
  275. static unsigned char    numtbl[LN+1]= {
  276.     0, 3, 4, 1, 5,99, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
  277.  
  278. makelist( str, tp )
  279. unsigned char    *str;
  280. T_IBUF    *tp;
  281. {
  282.     char    buf[80];
  283.     int    i;
  284.     *str= '\0';
  285.     for( i= 0 ; i< LN+1 ; i++ ){
  286.         if( numtbl[i] == 99 ){
  287.             strcat( str, makers( buf, tp ) );
  288.         }else if( i && strchr( tp[numtbl[i]].ibuf, ' ' ) ){
  289.             strcat( str, "\"" );
  290.             strcat( str, tp[numtbl[i]].ibuf );
  291.             strcat( str, "\"" );
  292.         }else if( *tp[numtbl[i]].ibuf == '\0' && i < 8 ){
  293.                 strcat( str, "\"\"" );
  294.         }else
  295.             strcat( str, tp[numtbl[i]].ibuf );
  296.         strcat( str, " " );
  297.     }
  298. }
  299.  
  300. #define    SY    (12*15+16)
  301. #define    SALL    (XO+6-2)
  302. #define    SCAN    (XO+43*6-2)
  303. #define    SSET    (XO+50*6-2)
  304.  
  305. DrawSetRS( dp, tp )
  306. DrawBuf    *dp;
  307. T_IBUF    *tp;
  308. {
  309.     DrawBuf    *dbuf= dp;
  310.     unsigned short    i;
  311.     for( i= 0 ; i< 7 ; i++ ){
  312.         DrawSetSymbol( dp++, XO+i*8*6+2, SY-21,
  313.                 rstbl[i].rs[tp[i].rs], ATTR, FONT );
  314.         DrawSetLine( dp++, XO+i*8*6-2+2, SY-23,
  315.             (i==6 ? 2:0)+ XO+i*8*6+42+1+2, SY-23+14,
  316.                 ShadowDown, OptionShadow );
  317.     }
  318.     return    dp-dbuf;
  319. }
  320.  
  321. InputExec( wp, info )
  322. WindowID    wp;
  323. EventInfo    *info;
  324. {
  325.     DrawBuf    dbuf[LN*8+20],
  326.         *dp= dbuf;
  327.     T_IBUF    *tp;
  328.     unsigned short    i, j;
  329.     switch( info->option ){
  330.     case EventRedraw:
  331.         tp= WindowGetClientPointer(wp);
  332.         DrawSetClear( dp++, attr&AttrReverse?attr&3:0 );
  333.         for( i= 0 ; i< LN ; i++ ){
  334.             DrawSetSymbol( dp++, tb[i].x, tb[i].y, tb[i].title,
  335.                                 ATTR, FONT );
  336.             dp+= InputSetDraw( dp, &tp[i].ip );
  337.             DrawSetLine( dp++,    tp[i].ip.x1-BOFF,
  338.                         tp[i].ip.y1-BOFF,
  339.                         tp[i].ip.x2+BOFF+7,
  340.                         tp[i].ip.y2+BOFF,
  341.                         ShadowDown, OptionShadow );
  342.         }
  343.         DrawSetSymbol( dp++, SALL+2, SY,
  344. /*        "全データ転送                       追加   取消   書込",*/
  345.         "全データ転送                              取消   登録",
  346.             ATTR, FONT );
  347.         DrawSetLine( dp++, SALL, SY-2, SALL+6*12+4, SY+14, ShadowUp, OptionShadow );
  348. #if 1
  349.         DrawSetLine( dp++, SCAN, SY-2, SCAN+4*6+4, SY+14, ShadowUp, OptionShadow );
  350.         DrawSetLine( dp++, SSET, SY-2, SSET+4*6+4, SY+14, ShadowUp, OptionShadow );
  351. #endif
  352.         DrawSetLine( dp++, XO, SY-6, tp[3].ip.x2+BOFF+7, SY+18, ShadowDown, OptionShadow );
  353.         dp+= DrawSetRS( dp, tp );
  354.         WindowDraw( wp, dbuf, dp-dbuf );
  355.         return    TRUE;
  356.     case EventKey:
  357.         tp= WindowGetClientPointer(wp);
  358.         i=  WindowGetClientData(wp);
  359.         WindowDraw( wp, dbuf, InputSetCursorVisible( dbuf, &tp[i].ip, FALSE ) );
  360.         switch( info->KeyCode ){
  361.         case FuncKey+1:
  362.             i= 0;
  363.             break;
  364.         case FuncKey+2:
  365.             i= LN-1;
  366.             break;
  367.         case Ctrl('e'):
  368.         case Ctrl('p'):
  369.         case FuncKeyUp:
  370.             i= (i ? i : LN)-1;
  371.             break;
  372.         case Ctrl('x'):
  373.         case Ctrl('n'):
  374.         case FuncKeyDown:
  375.         case '\r':
  376.         case '\n':
  377.             if( ++i >= LN )
  378.                 i= 0;
  379.             break;
  380.         case FuncKey+20:
  381.             info->option= EventClose;
  382.             WindowSendEvent( wp, info );
  383.             return    TRUE;
  384.         case FuncKey+6:
  385.             return    TRUE;
  386.         default:
  387.             WindowDraw( wp, dbuf, InputKey( dbuf, &tp[i].ip,
  388.                     info->KeyCode, info->ShiftStat ) );
  389.             break;
  390.         }
  391.         WindowDraw( wp, dbuf, InputSetCursorVisible( dbuf, &tp[i].ip, TRUE ) );
  392.         WindowSetClientData( wp, i, tp );
  393.         return    TRUE;
  394.     case EventMouseSwitch:
  395.         tp= WindowGetClientPointer(wp);
  396.         i=  WindowGetClientData(wp);
  397.         if( info->LeftON ){
  398.             static char    *dummy[LN+3],
  399.                     dmbuf[80];
  400.             if( info->x >= SALL && info->y >= SY-2 &&
  401.                 info->x <= (SALL+6*12+4) && info->y <= SY+14 ){
  402.                 makers( dmbuf, tp );
  403.                 dummy[0]= "*";
  404.                 dummy[1]= dmbuf;
  405.                 dummy[LN+3-1]= NULL;
  406.                 for( j= 0 ; j< LN ; j++ )
  407.                     dummy[j+2]= tp[j].ibuf;
  408.                 SendData( wp, info, UserStrings, dummy );
  409.             }else if( info->y >= SY-23 && info->y < SY-23+14 ){
  410.                 *dmbuf= '*';
  411.                 makers( dmbuf+1, tp );
  412.                 SendData( wp, info, UserString, dmbuf );
  413. #if 1
  414.             }else if( info->x >= SCAN && info->y >= SY-2 &&
  415.                 info->x <= (SCAN+6*4+4) && info->y <= SY+14 ){
  416.                 info->option= EventClose;
  417.                 WindowSendEvent( wp, info );
  418.                 return    TRUE;
  419.             }else if( info->x >= SSET && info->y >= SY-2 &&
  420.                 info->x <= (SSET+6*4+4) && info->y <= SY+14 ){
  421.                 if( mod_netlist( tp, FALSE ) ){
  422.                     info->option= EventClose;
  423.                     WindowSendEvent( wp, info );
  424.                 }
  425.                 return    TRUE;
  426. /*                char    lbuf[512];
  427.                 makelist( lbuf, tp );
  428.                 add_netlist( lbuf, tp->ibuf );*/
  429. #endif
  430.             }else for( j= 0 ; j< LN ; j++ ){
  431.                 if( info->x >= tb[j].x &&
  432.                         info->x <= tp[j].ip.x2+8 &&
  433.                         info->y >= tb[j].y &&
  434.                         info->y <= tp[j].ip.y2+2 ){
  435.                     WindowDraw( wp, dbuf, InputSetCursorVisible( dbuf, &tp[i].ip, FALSE ) );
  436.                     WindowDraw( wp, dbuf, InputSetCursorVisible( dbuf, &tp[i=j].ip, TRUE ) );
  437.                     SendData( wp, info, UserString, tp[i].ibuf );
  438.                     break;
  439.                 }
  440.             }
  441.         }else if( info->RightON ){
  442.             int    x, y;
  443.             char    *p;
  444.             WindowGetScreenPosition( wp, &x, &y );
  445.             if( info->y >= SY-23 && info->y <= SY-23+14 ){
  446.                 int    code;
  447.                 j= (info->x-XO)/(8*6);
  448.                 if( j >= 7 )
  449.                     return    TRUE;
  450.                 code= PopUpMenu( info->x+x-2, info->y+y+1,
  451.                     rstbl[j].rs, rstbl[j].len, FONT );
  452.                 if( code >= 0 ){
  453.                     tp[j].rs= code;
  454.                     DrawSetSymbol( dbuf, XO+j*8*6+2, SY-21,
  455.                     rstbl[j].rs[tp[j].rs], ATTR, FONT );
  456. /*    DrawSetLine( dp++, XO+i*8*6-2+2, SY-23,
  457.     (i==6 ? 2:0)+ XO+i*8*6+42+1+2, SY-23+14,
  458.     ShadowDown, OptionShadow );*/
  459.                     WindowDraw( wp, dbuf, 1 );
  460.                 }
  461.             }else switch( PopUpMenu( x+info->x-2, y+info->y+1,
  462.                         pmenu, MENUS, FONT ) ){
  463.             case 0:
  464.                 if( p= WindowGetCommon( "Clip Board", 0 ) ){
  465.                     info->option= EventUser;
  466.                     info->ComData= UserPaste;
  467.                     info->ComBuffer= p;
  468.                     WindowSendEvent( wp, info );
  469.                 break;
  470.                 }
  471.             case 1: /* 変更 */
  472.                 if( mod_netlist( tp, FALSE ) ){
  473.                     info->option= EventClose;
  474.                     WindowSendEvent( wp, info );
  475.                 }
  476.                 return    TRUE;
  477.             case 3: /* 削除 */
  478.                 makelist( Yankbuf, tp );
  479.                 mod_netlist( tp, TRUE );
  480. /*                add_netlist( "", tp->ibuf );*/
  481.                 break;
  482.             case 5:
  483.                 for( j= 0 ; j< LN ; j++ ){
  484.                     *tp[j].ibuf= '\0';
  485.                     tp[j].ip.cur= 0;
  486.                     tp[j].ip.curflag= FALSE;
  487.                     tp[j].rs= 0;
  488.                 }
  489.                 i= 0;
  490.                 tp[0].rs= 2;
  491.                 tp[0].ip.curflag= TRUE;
  492.                 WindowSetClientData( wp, i, tp );
  493.                 WindowRedraw( wp );
  494.                 return    TRUE;
  495.             case 7:
  496.                 info->option= EventClose;
  497.                 WindowSendEvent( wp, info );
  498.                 return    TRUE;
  499.             }
  500.         }
  501.         WindowSetClientData( wp, i, tp );
  502.         return    TRUE;
  503.     case EventIconify:
  504.         tp= WindowGetClientPointer(wp);
  505.         IconEnt( wp, *tp[3].ibuf ? tp[3].ibuf : "k20menu Input", ATTR, FONT );
  506.         return    TRUE;
  507.     case EventOpen:
  508.         WindowSetClientData( wp, 0, tpi );
  509.         for( i= 0 ; i< LN ; i++ ){
  510. #if DEBUG
  511.             *tpi[i].ibuf= '\0';
  512. #endif
  513.             InputSet( &tpi[i].ip,
  514.                 tb[i].x+strlen(tb[i].title)*6+IOFF,
  515.                 tb[i].y,
  516.                 tpi[i].ibuf, tb[i].imax, ATTR, FONT );
  517.             tpi[i].ip.curflag= FALSE;
  518.             tpi[i].ip.cur= strlen( tpi[i].ip.str );
  519. /*            tpi[i].rs= 0;*/
  520.         }
  521.         tpi->ip.curflag= FALSE;
  522.         WindowRedraw( wp );
  523.         WindowSetEventAttr( wp, EventOpenON|EventCloseON|EventRedrawON|
  524.             EventMouseSwitchON|EventIconifyON|EventUserON|
  525.             EventKeyON|EventMouseEnterON|EventMouseOutON );
  526.         return    TRUE;
  527.     case EventClose:
  528.         tp= WindowGetClientPointer(wp);
  529.         WindowClose( wp );
  530.         free( tp );
  531. #if DEBUG
  532.         WindowConnectionClose();
  533. #endif
  534.         return    TRUE;
  535.     case EventMouseEnter:
  536.     case EventMouseOut:
  537.         tp= WindowGetClientPointer(wp);
  538.         i=  WindowGetClientData(wp);
  539.         WindowDraw( wp, dbuf, InputSetCursorVisible( dbuf, &tp[i].ip,
  540.             info->option == EventMouseEnter ) );
  541.         return    TRUE;
  542.     case EventUser:
  543.         switch( info->ComData ){
  544.         unsigned char    *p, **pp;
  545.         case UserStrings:
  546.             pp= info->ComBuffer;
  547.             info->option= EventKey;
  548.             info->ShiftStat= 0;
  549.             if( *pp && **pp == '*' ){
  550.                 info->KeyCode= FuncKey+1;
  551.                 InputExec( wp, info );
  552.                 if( *++pp ){
  553.                     tp= WindowGetClientPointer(wp);
  554.                     i=  WindowGetClientData(wp);
  555.                     rs2set( tp, *pp++ );
  556.                     WindowDraw( wp, dbuf, DrawSetRS( dbuf, tp ) );
  557.                     WindowSetClientData( wp, i, tp );
  558.                 }
  559.             }
  560.             for(; *pp ;){
  561.                 info->KeyCode= Ctrl('u');
  562.                 InputExec( wp, info );
  563.                 for( p= *pp++ ; *p ;){
  564.                     info->KeyCode= *p++;
  565.                     InputExec( wp, info );
  566.                 }
  567.                 info->KeyCode= '\r';
  568.                 InputExec( wp, info );
  569.             }
  570.             break;
  571.         case UserString:
  572.             p= info->ComBuffer;
  573.             if( *p == '*' && p[1] == '"' ){
  574.                 tp= WindowGetClientPointer(wp);
  575.                 i=  WindowGetClientData(wp);
  576.                 rs2set( tp, p+1 );
  577.                 WindowDraw( wp, dbuf, DrawSetRS( dbuf, tp ) );
  578.                 WindowSetClientData( wp, i, tp );
  579.                 break;
  580.             }
  581.         case UserPaste:
  582.             info->option= EventKey;
  583.             info->ShiftStat= 0;
  584.             for( p= info->ComBuffer ; *p ;){
  585.                 info->KeyCode= *p++;
  586.                 InputExec( wp, info );
  587.             }
  588.             break;
  589.         }
  590.         return    TRUE;
  591.     }
  592.     return    FALSE;
  593. }
  594.  
  595. searchparam( tbl, key, n )
  596. char    **tbl;
  597. char    *key;
  598. {
  599.     int    i;
  600.     for( i= 0 ; i< n ; i++ ){
  601. /*ConsolePrintf( "[%s][%s]\r\n", tbl[i], key );*/
  602.         if( !strcmp( tbl[i], key ) )
  603.             return    i;
  604.     }
  605.     return    -1;
  606. }
  607.  
  608. rs2set( tp, p )
  609. T_IBUF    *tp;
  610. char    *p;
  611. {
  612.     char    bi[80];
  613.     int    i, l;
  614.     if( *p == '"' ){
  615.         if( p[i= strlen(p)-1] == '"' )
  616.             p[i]= '\0';
  617.         p++;
  618.     }
  619.     for( i= 0 ; i< 7 ; i++ ){
  620.         p= (char*)getword( bi, p );
  621.         if( (l= searchparam( rstbl[i].ss, bi, rstbl[i].len ))>= 0 ){
  622.             tp[i].rs= l;
  623.         }else
  624.             tp[i].rs= 0;
  625.     }
  626. }
  627.  
  628. OpenDiag( x, y, ptr )
  629. char    *ptr;
  630. {
  631.     ConsoleOpen();
  632.     if( tpi= (T_IBUF*)malloc( LN*sizeof(T_IBUF) ) ){
  633.         memset( tpi, 0, LN*sizeof(T_IBUF) );
  634.         tpi[0].rs= 2;
  635.         if( *ptr ){
  636.             int    i;
  637.             for( i= 0 ; i< LN+1 ; i++ ){
  638.                 if( numtbl[i] == 99 ){
  639.                     char    buf[80];
  640.                     ptr= (char*)getword( buf, ptr );
  641.                     rs2set( tpi, buf );
  642.                 }else{
  643.                     ptr= (char*)getword( tpi[numtbl[i]].ibuf, ptr );
  644.                 }
  645.             }
  646.         }
  647.         WindowTitleOpen( x, y, HS, VS, NULL, "Input", Close|Push|Icon,
  648.                     InputExec);
  649.     }else{
  650.         ConsolePrint( "k20menu:malloc error.\r\n" );
  651. #if DEBUG
  652.         WindowConnectionClose();
  653. #endif
  654.     }
  655. }
  656.  
  657. #if DEBUG
  658. int    WindowHeapSize= 20*1024;
  659. WindowMain()
  660. {
  661.     OpenDiag( 10, 10 );
  662. }
  663. #endif
  664.